package com.blovesoft.tokenup.ui.mine;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.SpanUtils;
import com.blovesoft.tokenup.R;
import com.blovesoft.tokenup.util.DialogHelper;
import com.llkj.common.base.BaseFragment;
import com.llkj.common.di.component.AppComponent;
import com.llkj.common.util.GlideApp;
import com.llkj.common.widget.titlebar.TitleBar;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * author: zhu.px
 * e-mail: 1271901673@qq.com
 * time  : 2018/5/28
 * desc  : 我的
 */
public class MineFragment extends BaseFragment {

    @BindView(R.id.title_bar)
    TitleBar titleBar;
    @BindView(R.id.iv_head)
    ImageView ivHead;
    @BindView(R.id.tv_username)
    TextView tvUsername;
    @BindView(R.id.tv_phone)
    TextView tvPhone;
    @BindView(R.id.tv_balance)
    TextView tvBalance;

    public static MineFragment newInstance() {
        Bundle args = new Bundle();
        MineFragment fragment = new MineFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayoutResId() {
        return R.layout.fragment_mine;
    }

    @Override
    public boolean useEventBus() {
        return false;
    }

    @Override
    public void initView() {
        GlideApp.with(this)
                .load(R.drawable.ic_launcher_background)
                .circleCrop()
                .into(ivHead);
    }

    @Override
    public void initData() {
        tvBalance.setText(new SpanUtils()
                .append("0.00").setFontSize(18, true)
                .append(getString(R.string.tct)).setFontSize(12, true)
                .create());
    }

    @Override
    public void getBundleExtras(Bundle extras) {

    }

    @Override
    public void initListener() {

    }

    @Override
    public void setupFragmentComponent(@NonNull AppComponent appComponent) {

    }

    @OnClick({R.id.tv_contact_us, R.id.tv_public_number, R.id.tv_exit, R.id.rl_balance
            , R.id.view_top})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_contact_us:
                startActivity(ContactUsActivity.class);
                break;
            case R.id.tv_public_number:
                startActivity(PublicNumberActivity.class);
                break;
            case R.id.tv_exit:
                DialogHelper.showDialog(mContext, "是否退出登录?", "退出", getString(R.string.cancel), new DialogHelper.DialogInterface() {
                    @Override
                    public void onPositive() {

                    }

                    @Override
                    public void onNegative() {

                    }
                });
                break;
            case R.id.rl_balance:
                startActivity(MyWalletActivity.class);
                break;
            case R.id.view_top:
                startActivity(UserInfoActivity.class);
                break;
            default:
                break;
        }
    }

}
